package com.orangeumbrella;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.easylib.base.BaseActivity;
import com.easylib.utils.ImageLoadUtils;
import com.guyj.CommonAdapter;
import com.guyj.base.ViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 商城客服
 */
public class MallServiceActivity extends BaseActivity {

    @Bind(R.id.tv_product)
    TextView tvProduct;
    @Bind(R.id.tv_service)
    TextView tvService;
    @Bind(R.id.recycler)
    RecyclerView recycler;
    @Bind(R.id.activity_mall_service)
    LinearLayout activityMallService;
    LinearLayoutManager llm;
    CommonAdapter adapter1, adapter2;
    List<String> datas1, datas2;

    @Override
    public int getContentViewId() {
        return R.layout.activity_mall_service;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {

    }

    @Override
    protected void initVariable() {
        llm = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
        datas1 = new ArrayList<>();
        datas2 = new ArrayList<>();
        datas1.add("1");
        datas1.add("1");
        datas1.add("1");
        datas1.add("1");
        datas1.add("1");
        datas2.add("产品问题");
        datas2.add("配送问题");
        datas2.add("改进建议");
        adapter2 = new CommonAdapter<String>(mContext, R.layout.item_title, datas2) {
            @Override
            protected void convert(ViewHolder viewHolder, final String o, int i) {
                viewHolder.setText(R.id.tv_title, o);
                viewHolder.setOnClickListener(R.id.ll_root, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(mContext, InputActivity.class);
                        intent.putExtra("title", o);
                        startActivity(intent);
                    }
                });
            }
        };
    }

    @Override
    protected void processLogic(Bundle savedInstanceState) {
        recycler.setLayoutManager(llm);
        recycler.setAdapter(adapter1 = new CommonAdapter<String>(mContext, R.layout.item_product, datas1) {
            @Override
            protected void convert(ViewHolder viewHolder, String o, int i) {
                ImageLoadUtils.into(R.drawable.product, (ImageView) viewHolder.getView(R.id.iv_product));
            }
        });
    }

    @OnClick({R.id.tv_product, R.id.tv_service})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_product:
                recycler.setAdapter(adapter1);
                break;
            case R.id.tv_service:
                recycler.setAdapter(adapter2);
                break;
        }
    }
}
